home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: ncrgw2.ncr.com!ncrhub2!lznj2!lziss3!ucseng!news
- From: Bill Himmelstoss <whimmel@ucs.att.com>
- Subject: Virtual functions and BC452
- Content-Type: text/plain; charset=us-ascii
- Message-ID: <30EBDABA.7DE1@ucs.att.com>
- Sender: news@ucseng.ucs.att.com
- Content-Transfer-Encoding: 7bit
- Organization: AT&T Universal Card Services
- Mime-Version: 1.0
- Date: Thu, 4 Jan 1996 13:48:42 GMT
- X-Mailer: Mozilla 2.0b3 (Win95; I)
-
- Hi! I'm porting some Borland Pascal code to C++ and am having trouble with virtual functions.
- This stuff works great in BP, but not in BC. Here's an example:
-
- class Base {
- public:
- Base() {}
- protected:
- void cheeky();
- virtual void monkey();
- };
-
- void cheeky() {
- monkey();
- }
-
- class Derived: public Base {
- protected:
- virtual void monkey();
- }
-
- ...
-
- Derived d;
- d.cheeky();
-
- This Base::cheeky() is calling Base::monkey() instead of Derived::monkey(). Why?
-
- Ok, now for the ringer: It works properly under Turbo Debugger!
-
- Billl
-
-
- --
- -----------------------------------------------------------
- Bill Himmelstoss whimmel@ucs.att.com
- #include <std\disclaimer.h> Developer, AT&T Universal Card
- -----------------------------------------------------------
-